home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / Container / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  21.8 KB  |  669 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Frame.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "Container.hpp"
  11.  
  12. #ifndef FRAME_H
  13. #include "Frame.h"
  14. #endif
  15.  
  16. #ifndef PART_H
  17. #include "Part.h"
  18. #endif
  19.  
  20. #ifndef DEFINES_K
  21. #include "Defines.k"
  22. #endif
  23.  
  24. #ifndef COMMANDS_H
  25. #include "Commands.h"
  26. #endif
  27.  
  28. #ifndef SELECT_H
  29. #include "Select.h"
  30. #endif
  31.  
  32. #ifndef PROXY_H
  33. #include "Proxy.h"
  34. #endif
  35.  
  36. #ifndef VIEW_H
  37. #include "View.h"
  38. #endif
  39.  
  40. #ifndef CONTENT_H
  41. #include "Content.h"
  42. #endif
  43.  
  44. // ----- Framework Layer -----
  45.  
  46. #ifndef FWCONTXT_H
  47. #include "FWContxt.h"
  48. #endif
  49.  
  50. #ifndef FWUTIL_H
  51. #include "FWUtil.h"
  52. #endif
  53.  
  54. #ifndef FWPRESEN_H
  55. #include "FWPresen.h"
  56. #endif
  57.  
  58. #ifndef FWSCROLR_H
  59. #include "FWScrolr.h"
  60. #endif
  61.  
  62. #ifndef FWSCLBAR_H
  63. #include "FWSclBar.h"
  64. #endif
  65.  
  66. #ifndef FWGROWBX_H
  67. #include "FWGrowBx.h"
  68. #endif
  69.  
  70. #ifndef FWFCTCLP_H
  71. #include "FWFctClp.h"
  72. #endif
  73.  
  74. // ----- OS Layer -----
  75.  
  76. #ifndef FWMENU_H
  77. #include "FWMenu.h"
  78. #endif
  79.  
  80. #ifndef FWRECSHP_H
  81. #include "FWRecShp.h"
  82. #endif
  83.  
  84. #ifndef FWODGEOM_H
  85. #include "FWODGeom.h"
  86. #endif
  87.  
  88. // ----- OpenDoc Includes -----
  89.  
  90. #ifndef SOM_Module_OpenDoc_Commands_defined
  91. #include <CmdDefs.xh>
  92. #endif
  93.  
  94. #ifndef SOM_Module_OpenDoc_StdProps_defined
  95. #include <StdProps.xh>
  96. #endif
  97.  
  98. #ifndef SOM_ODSession_xh
  99. #include <ODSessn.xh>
  100. #endif
  101.  
  102. #ifndef SOM_ODDispatcher_xh
  103. #include <Disptch.xh>
  104. #endif
  105.  
  106. //========================================================================================
  107. // Runtime Information
  108. //========================================================================================
  109.  
  110. #ifdef FW_BUILD_MAC
  111. #pragma segment odfcontainer
  112. #endif
  113.  
  114. FW_DEFINE_CLASS_M1(CContainerFrame, FW_CEmbeddingFrame)
  115. FW_DEFINE_AUTO(CContainerFrame)
  116.  
  117. //========================================================================================
  118. // CContainerFrame
  119. //========================================================================================
  120.  
  121. //----------------------------------------------------------------------------------------
  122. // CContainerFrame::CContainerFrame
  123. //----------------------------------------------------------------------------------------
  124.  
  125. CContainerFrame::CContainerFrame(Environment* ev, 
  126.                                 ODFrame* odFrame, 
  127.                                 FW_CPresentation* presentation, 
  128.                                 CContainerPart* part,
  129.                                 FW_ResourceId id) :
  130.     FW_CEmbeddingFrame(ev, odFrame, presentation, part, id),
  131.     FW_MDraggableFrame(ev, this),
  132.     FW_MDroppableFrame(ev, this),
  133.     fContainerPart(part),
  134.     fSelection((CContainerSelection*)GetPresentation(ev)->GetSelection(ev)),
  135.     fZoomFactor(FW_kFixedPos1)
  136. {    
  137.     FW_END_CONSTRUCTOR
  138. }
  139.  
  140. //----------------------------------------------------------------------------------------
  141. // CContainerFrame::~CContainerFrame
  142. //----------------------------------------------------------------------------------------
  143.  
  144. CContainerFrame::~CContainerFrame()
  145. {
  146.     FW_START_DESTRUCTOR
  147. }
  148.  
  149. //----------------------------------------------------------------------------------------
  150. //    CContainerFrame::DoAdjustMenus
  151. //----------------------------------------------------------------------------------------
  152.  
  153. FW_Boolean CContainerFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
  154. {
  155.     // ----- Edit Menu -----
  156.     if (hasMenuFocus)
  157.     {
  158.         menuBar->EnableCommand(ev, kODCommandPaste, HasPropertyOnClipboard(ev, kODPropContents, NULL)); // we don't care about the type
  159.         
  160.         ODTypeToken defaultViewType = GetPresentation(ev)->GetDefaultEmbeddedFrameViewType(ev);
  161.         menuBar->EnableAndCheckCommand(ev, cAsFrame, TRUE, defaultViewType == FW_CPart::gViewAsFrameToken);
  162.         menuBar->EnableAndCheckCommand(ev, cAsLargeIcon, TRUE, defaultViewType == FW_CPart::gViewAsLargeIconToken);
  163.         menuBar->EnableAndCheckCommand(ev, cAsSmallIcon, TRUE, defaultViewType == FW_CPart::gViewAsSmallIconToken);
  164.         menuBar->EnableAndCheckCommand(ev, cAsThumbnail, TRUE, defaultViewType == FW_CPart::gViewAsThumbnailToken);
  165.  
  166.         menuBar->EnableAndCheckCommand(ev, cZoom50, TRUE, fZoomFactor == FW_DoubleToFixed(.5));
  167.         menuBar->EnableAndCheckCommand(ev, cZoom100, TRUE, fZoomFactor == FW_kFixedPos1);
  168.         menuBar->EnableAndCheckCommand(ev, cZoom200, TRUE, fZoomFactor == FW_IntToFixed(2));
  169.     }
  170.     
  171.     return FALSE;
  172. }
  173.  
  174. //----------------------------------------------------------------------------------------
  175. //    CContainerFrame::ChangeZoomFactor
  176. //----------------------------------------------------------------------------------------
  177.  
  178. void CContainerFrame::ChangeZoomFactor(Environment* ev, FW_Fixed zoomFactor)
  179. {
  180.     fZoomFactor = zoomFactor;
  181.  
  182.     AdjustContentViewSize(ev, FALSE);
  183.  
  184.     FW_ASSERT(GetScroller(ev));
  185.     GetScroller(ev)->ScaleBy(ev, FW_CPoint(zoomFactor, zoomFactor));    // Will invalidate
  186. }
  187.  
  188. //----------------------------------------------------------------------------------------
  189. //    CContainerFrame::DoMenu
  190. //----------------------------------------------------------------------------------------
  191.  
  192. FW_Boolean CContainerFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
  193. {
  194.     FW_Boolean handled = TRUE;
  195.     
  196.     ODCommandID commandID = theMenuEvent.GetCommandID(ev);
  197.     switch (commandID)
  198.     {
  199.         case cZoom50:
  200.             if (fZoomFactor != FW_DoubleToFixed(0.5))
  201.                 ChangeZoomFactor(ev, FW_DoubleToFixed(0.5));
  202.             break;
  203.         case cZoom100:
  204.             if (fZoomFactor != FW_kFixedPos1)
  205.                 ChangeZoomFactor(ev, FW_kFixedPos1);
  206.             break;
  207.         case cZoom200:
  208.             if (fZoomFactor != FW_IntToFixed(2))
  209.                 ChangeZoomFactor(ev, FW_IntToFixed(2));
  210.             break;
  211.                     
  212.         case cAsFrame:
  213.             GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::gViewAsFrameToken);
  214.             break;
  215.         case cAsLargeIcon:
  216.             GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::gViewAsLargeIconToken);
  217.             break;
  218.         case cAsSmallIcon:
  219.             GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::gViewAsSmallIconToken);
  220.             break;
  221.         case cAsThumbnail:
  222.             GetPresentation(ev)->SetDefaultEmbeddedFrameViewType(ev, FW_CPart::gViewAsThumbnailToken);
  223.             break;
  224.             
  225.         default:
  226.             handled = FALSE;
  227.     }
  228.     
  229.     return handled;
  230. }
  231.  
  232. //----------------------------------------------------------------------------------------
  233. //    CContainerFrame::NewClipboardCommand
  234. //----------------------------------------------------------------------------------------
  235.  
  236. FW_CClipboardCommand* CContainerFrame::NewClipboardCommand(Environment* ev, ODCommandID commandID)
  237. {
  238.     return FW_NEW(CClipboardCommand, (ev, commandID, fContainerPart, this, fSelection, FW_kCanUndo));
  239. }
  240.  
  241. //----------------------------------------------------------------------------------------
  242. //    CContainerFrame::NewInsertCommand
  243. //----------------------------------------------------------------------------------------
  244.  
  245. FW_CInsertCommand* CContainerFrame::NewInsertCommand(Environment* ev, const FW_PFileSpecification& fileSpec)
  246. {
  247.     return FW_NEW(CInsertCommand, (ev, this, fileSpec, fSelection, FW_kCanUndo));
  248. }
  249.  
  250. //----------------------------------------------------------------------------------------
  251. //    CContainerFrame::DoActivateEvent
  252. //----------------------------------------------------------------------------------------
  253.  
  254. void CContainerFrame::DoActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent)
  255. {
  256.     if (HasSelectionFocus(ev))
  257.         fSelection->RenderAllHandles(ev, this);
  258. }
  259.  
  260. //----------------------------------------------------------------------------------------
  261. //    CContainerFrame::CanAcceptDrop
  262. //----------------------------------------------------------------------------------------
  263.  
  264. ODDragResult CContainerFrame::CanAcceptDrop(Environment* ev, ODDragItemIterator* dragInfo)
  265. {
  266.     return TRUE;
  267. }
  268.  
  269. //----------------------------------------------------------------------------------------
  270. //    CContainerFrame::AdjustZoomedWindowSize
  271. //----------------------------------------------------------------------------------------
  272.  
  273. void CContainerFrame::AdjustZoomedWindowSize(Environment* ev, FW_CPoint& proposedSize)
  274. {
  275.     proposedSize = fContainerPart->GetDrawingSize();
  276.     proposedSize.x *= fZoomFactor;
  277.     proposedSize.y *= fZoomFactor;
  278.  
  279.     FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
  280.  
  281.     proposedSize.x += sbSize.x + FW_IntToFixed(3);    // I want to leave a little space around
  282.     proposedSize.y += sbSize.y + FW_IntToFixed(3);
  283. }
  284.  
  285. //----------------------------------------------------------------------------------------
  286. //    CContainerFrame::AdjustWindowGrowLimits
  287. //----------------------------------------------------------------------------------------
  288.  
  289. void CContainerFrame::AdjustWindowGrowLimits(Environment* ev, FW_CPoint& minSize, FW_CPoint& maxSize)
  290. {
  291.     FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
  292.  
  293.     minSize.x = FW_IntToFixed(72) + sbSize.x;
  294.     minSize.y = FW_IntToFixed(72) + sbSize.y;
  295. }
  296.  
  297. //----------------------------------------------------------------------------------------
  298. //    CContainerFrame::GeometryChanged
  299. //----------------------------------------------------------------------------------------
  300. //    the geometry (clip shape, external or Internal transform) of one of my facet or one of my
  301. //    embedding facet as changed
  302.  
  303. void CContainerFrame::GeometryChanged(Environment* ev,
  304.                                 ODFacet* odFacet,
  305.                                 FW_Boolean clipShapeChanged,
  306.                                 FW_Boolean externalTransformChanged)
  307. {
  308.     FW_CEmbeddingFrame::GeometryChanged(ev, odFacet, clipShapeChanged, externalTransformChanged);
  309.     
  310.     FW_CFacetClipper facetClipper(ev, fContainerPart);
  311.     facetClipper.ClipEmbeddedFacets(ev, this, odFacet, NULL);
  312. }
  313.  
  314. //----------------------------------------------------------------------------------------
  315. //    CContainerFrame::CreateEmbeddedFacet
  316. //----------------------------------------------------------------------------------------
  317.  
  318. FW_DECLARE_THROW_POINT (CContainerFrame_CreateEmbeddedFacet);
  319.  
  320. ODFacet* CContainerFrame::CreateEmbeddedFacet(Environment* ev,
  321.                                         ODFacet* embeddingFacet,
  322.                                         FW_MProxy* proxy,
  323.                                         ODFrame* embeddedFrame,
  324.                                         ODShape* proposedClipShape)
  325. {
  326.     FW_CRect embeddedFrameBounds = ((CProxy*)proxy)->GetBounds(ev);
  327.     
  328.     FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, embeddedFrameBounds.TopLeft());
  329.  
  330.     FW_CHECK_THROW_POINT (CContainerFrame_CreateEmbeddedFacet);
  331.     return embeddingFacet->CreateEmbeddedFacet(ev,
  332.                                                 embeddedFrame,
  333.                                                 proposedClipShape,
  334.                                                 aqExternalTransform,
  335.                                                 NULL,                    // Canvas
  336.                                                 NULL,                    // biasCanvas
  337.                                                 NULL,                    // siblingFacet
  338.                                                 kODFrameInFront);
  339. }
  340.  
  341. //----------------------------------------------------------------------------------------
  342. //    CContainerFrame::PostCreateViewFromStream
  343. //----------------------------------------------------------------------------------------
  344. // PostCreateViewFromStream is called after subviews are created from resources.  
  345. // Add code which cannot be handled by current resource types.
  346.  
  347. void CContainerFrame::PostCreateViewFromStream(Environment* ev)
  348. {
  349.     // ----- Remove the grow-box and scroll-bars from non-root (i.e. embedded) frames
  350.     //        ("delete" will also remove a view from the list of subviews for that frame)
  351.     if (IsRoot(ev) == false) 
  352.     {
  353.         // Remove the GrowBox 
  354.         FW_CView* growBox = FindViewById(ev, kGrowBoxID);
  355.         FW_ASSERT(growBox);
  356.         delete growBox;    
  357.     
  358.         // Remove the scroll-bars from the scroller and then delete them
  359.         FW_CScrollBarScroller* scroller = FW_DYNAMIC_CAST(FW_CScrollBarScroller, GetScroller(ev));
  360.         FW_ASSERT(scroller);
  361.         FW_CScrollBar* hSB = scroller->GetScrollBar(ev, FW_kHorizontal);
  362.         FW_CScrollBar* vSB = scroller->GetScrollBar(ev, FW_kVertical);
  363.         
  364.         scroller->RemoveScrollBar(ev, FW_kHorizontal);
  365.         scroller->RemoveScrollBar(ev, FW_kVertical);
  366.         
  367.         delete hSB;
  368.         delete vSB;
  369.     }
  370.         
  371.     // WARNING: Make sure that classes created from resources won't be dead-stripped
  372.     FW_DO_NOT_DEAD_STRIP(FW_CGrowBox);
  373.     FW_DO_NOT_DEAD_STRIP(FW_CScrollBarScroller);
  374.     FW_DO_NOT_DEAD_STRIP(FW_CScrollBar);    
  375. }
  376.  
  377. //----------------------------------------------------------------------------------------
  378. // CContainerFrame::CreateSubViews
  379. //----------------------------------------------------------------------------------------
  380. #if 0
  381. // NOTE: This method is not used by default because views are created from resources.
  382. //         It was left to show how to create views by program instead of using resources. 
  383.     
  384. void CContainerFrame::CreateSubViews(Environment* ev)
  385. {        
  386.     FW_CRect frameRect = GetBounds(ev);    
  387.     FW_CRect contentRect = GetContentRect(ev);
  388.  
  389.     FW_CPoint drawingSize = fContainerPart->GetDrawingSize();
  390.     
  391.     // ----- Create the content view -----
  392.     FW_CRect drawViewBounds(contentRect);
  393.     if (drawViewBounds.Width() > drawingSize.x)
  394.         drawViewBounds.right = drawViewBounds.left + drawingSize.x;
  395.     if (drawViewBounds.Height() > drawingSize.y)
  396.         drawViewBounds.bottom = drawViewBounds.top + drawingSize.y;
  397.         
  398.     CContainerView* contentView = new CContainerView(ev, this, drawViewBounds, drawingSize, fContainerPart);
  399.     contentView->MakeContentView(ev);
  400.     
  401.     FW_CScrollBar* vertSB = NULL;
  402.     FW_CScrollBar* horzSB = NULL;
  403.     // ----- Create scroll bars and grow box in root frame only -----
  404.     if (IsRoot(ev))
  405.     {    
  406.         // ----- Create the vertical scroll bar
  407.         FW_CRect vertSbRect(contentRect.right, frameRect.top - FW_kFixedPos1, 
  408.                         frameRect.right + FW_kFixedPos1, contentRect.bottom + FW_kFixedPos1);
  409.         vertSB = FW_NEW(FW_CScrollBar, (ev, this, 0, vertSbRect));
  410.         
  411.         // ----- Create the horizontal scroll bar
  412.         FW_CRect horzSbRect(frameRect.left - FW_kFixedPos1, contentRect.bottom, 
  413.                     contentRect.right + FW_kFixedPos1, frameRect.bottom + FW_kFixedPos1);
  414.         horzSB = FW_NEW(FW_CScrollBar, (ev, this, 0, horzSbRect));
  415.         
  416.         // ----- Create the GrowBox gadget
  417.         FW_CGrowBox* growBox = new FW_CGrowBox(ev, this, 0, contentRect.BotRight());
  418.     }
  419.  
  420.     // ----- add a scroller to the Frame -----
  421.     FW_CScroller* scroller = FW_NEW(FW_CScrollBarScroller, (ev, this, horzSB, vertSB));
  422.     AdoptScroller(ev, scroller);
  423. }
  424. #endif
  425.  
  426. //----------------------------------------------------------------------------------------
  427. // CContainerFrame::GetContentRect
  428. //----------------------------------------------------------------------------------------
  429.  
  430. FW_CRect CContainerFrame::GetContentRect(Environment* ev) const
  431. {
  432.     FW_CRect contentRect = GetBounds(ev);
  433.  
  434.     if (IsRoot(ev))
  435.     {
  436.         FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
  437.     
  438.         contentRect.bottom -= sbSize.y;
  439.         contentRect.right -= sbSize.x;
  440.     }
  441.     
  442.     return contentRect;
  443. }
  444.  
  445. //----------------------------------------------------------------------------------------
  446. // CContainerFrame::AdjustContentViewSize
  447. //----------------------------------------------------------------------------------------
  448.  
  449. void CContainerFrame::AdjustContentViewSize(Environment* ev, FW_Boolean refresh)
  450. {
  451.     FW_CRect contentRect = GetContentRect(ev);    
  452.  
  453.     FW_CPoint drawingSize = fContainerPart->GetDrawingSize();
  454.     
  455.     // ----- I need to take into account the zoom factor -----
  456.     drawingSize.x *= fZoomFactor;
  457.     drawingSize.y *= fZoomFactor;
  458.  
  459.     FW_CPoint drawViewSize(FW_Minimum(drawingSize.x, contentRect.Width()),
  460.                             FW_Minimum(drawingSize.y, contentRect.Height()));
  461.  
  462.     FW_CPoint currentSize = GetContentView(ev)->GetSize(ev);
  463.     if (currentSize != drawViewSize)
  464.     {
  465.         GetContentView(ev)->SetSize(ev, drawViewSize, refresh);
  466.     }
  467. }
  468.  
  469. //----------------------------------------------------------------------------------------
  470. // CContainerFrame::Draw
  471. //----------------------------------------------------------------------------------------
  472.  
  473. void CContainerFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
  474. {    
  475.     FW_CViewContext vc(ev, this, odFacet, invalidShape);
  476.  
  477.     FW_CSuperView* contentView = GetContentView(ev);
  478.     FW_CRect contentRect = GetContentRect(ev);
  479.     FW_CRect contentBounds = contentView->GetBounds(ev);
  480.     
  481.     // Note: in this container we always have contentRect == contentBounds because the
  482.     //        content view takes up the whole space, so we could remove this Draw method.
  483.     //        We left it to show you what could be done to draw in the frame outside the 
  484.     //        content view (see also the Draw example)
  485.     if (contentRect != contentBounds)
  486.     {
  487.         FW_CAcquiredODShape shape1 = ::FW_NewODShape(ev, contentRect);
  488.         FW_CAcquiredODShape shape2 = ::FW_NewODShape(ev, contentBounds);
  489.         shape1->Subtract(ev, shape2);        
  490.         
  491.         FW_CRegionShape::RenderRegion(vc, shape1, FW_kFill, FW_kRGBLightGray);
  492.             
  493.         contentBounds.Inset(FW_kFixedNeg1, FW_kFixedNeg1);
  494.         FW_CRectShape::RenderRect(vc, contentBounds, FW_kFrame);
  495.     }
  496. }
  497.  
  498. //----------------------------------------------------------------------------------------
  499. // CContainerFrame::DoMouseDownInEmbeddedFrameBorder
  500. //----------------------------------------------------------------------------------------
  501.  
  502. FW_Boolean CContainerFrame::DoMouseDownInEmbeddedFrameBorder(Environment* ev, 
  503.                                                         const FW_CBorderMouseEvent& theBorderMouseEvent)
  504. {    
  505.     Drag(ev, theBorderMouseEvent);
  506.     
  507.     return TRUE;
  508. }
  509.  
  510. //----------------------------------------------------------------------------------------
  511. // CContainerFrame::DoMouseDownInEmbeddedFrame
  512. //----------------------------------------------------------------------------------------
  513.  
  514. FW_Boolean CContainerFrame::DoMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent)
  515. {
  516.     FW_Boolean handled = FALSE;
  517.     
  518.     if (theEmbeddedMouseEvent.GetNumberOfClicks(ev) > 1)
  519.     {
  520.         OpenSelection(ev);
  521.         handled = TRUE;
  522.     }
  523.     
  524.     return handled;
  525. }
  526.  
  527. //----------------------------------------------------------------------------------------
  528. //    CContainerFrame::NewDragCommand
  529. //----------------------------------------------------------------------------------------
  530.  
  531. FW_CDragCommand* CContainerFrame::NewDragCommand(Environment* ev, FW_CFrame* theFrame, const FW_CMouseEvent& theMouseEvent)
  532. {
  533.     return FW_NEW(CDragCommand, (ev, fContainerPart, theFrame,
  534.                                 fSelection,
  535.                                 FW_kCanUndo));
  536. }
  537.  
  538. //----------------------------------------------------------------------------------------
  539. //    CContainerFrame::NewDropCommand
  540. //----------------------------------------------------------------------------------------
  541.  
  542. FW_CDropCommand* CContainerFrame::NewDropCommand(Environment* ev,
  543.                                             FW_CFrame* frame,
  544.                                             ODDragItemIterator* dropInfo, 
  545.                                             ODFacet* facet, 
  546.                                             const FW_CPoint& dropPoint)
  547. {
  548.     return FW_NEW(CDropCommand, (ev, fContainerPart, frame,
  549.                                 dropInfo, facet, dropPoint,
  550.                                 FW_kCanUndo));
  551. }
  552.  
  553. //----------------------------------------------------------------------------------------
  554. //    CContainerFrame::ExternalizeFrame
  555. //----------------------------------------------------------------------------------------
  556.  
  557. void CContainerFrame::ExternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
  558. {
  559.     FW_CEmbeddingFrame::ExternalizeFrame(ev, storageUnitView);
  560.     
  561.     FW_PStorageUnitSink suSink(ev, storageUnitView);
  562.     FW_CWritableStream stream(suSink);
  563.     
  564.     stream << fZoomFactor;
  565. }
  566.  
  567. //----------------------------------------------------------------------------------------
  568. //    CContainerFrame::InternalizeFrame
  569. //----------------------------------------------------------------------------------------
  570.  
  571. void CContainerFrame::InternalizeFrame(Environment* ev, ODStorageUnitView* storageUnitView)
  572. {
  573.     FW_CEmbeddingFrame::InternalizeFrame(ev, storageUnitView);
  574.  
  575.     FW_PStorageUnitSink suSink(ev, storageUnitView);
  576.     FW_PBufferedSink sink(ev, suSink);
  577.     FW_CReadableStream stream(sink);
  578.     
  579.     stream >> fZoomFactor;
  580. }
  581.  
  582. //----------------------------------------------------------------------------------------
  583. //    CContainerFrame::FocusStateChanged
  584. //----------------------------------------------------------------------------------------
  585.  
  586. void CContainerFrame::FocusStateChanged(Environment* ev, ODTypeToken focus, FW_Boolean newState, ODFrame* newOwner)
  587. {
  588.     FW_CEmbeddingFrame::FocusStateChanged(ev, focus, newState, newOwner);
  589.     
  590.     if (focus == FW_CPart::gSelectionFocusToken)
  591.     {
  592.         //    • If I get the selection focus I redraw the handles only if the window is not active
  593.         //    if the window is active they already have been redrawn by DoActivateEvent
  594.         //    • If I am loosing the selection focus I redraw the handles only if the window is active
  595.         //    if the window is not active they already have been redrawn by DoActivateEvent
  596.         //    The events order is:
  597.         //        - Window 1 deactivated
  598.         //        - Frame 1 lose selection focus
  599.         //        - Frame 2 gain selection focus
  600.         //        - Window 2 activated
  601.         FW_Boolean windowActive = GetWindow(ev)->IsActive(ev);
  602.         FW_Boolean hilite = newState ? !windowActive : windowActive;
  603.         if (hilite)
  604.             fSelection->RenderAllHandles(ev, this);
  605.     }
  606. }
  607.  
  608. //----------------------------------------------------------------------------------------
  609. //    CContainerFrame::EmbeddedFrameRequested
  610. //----------------------------------------------------------------------------------------
  611.  
  612. FW_MProxy* CContainerFrame::EmbeddedFrameRequested(Environment *ev,
  613.                                                     FW_MProxy* baseProxy,
  614.                                                     ODFrame* baseFrame,
  615.                                                     ODShape* frameShape,
  616.                                                     ODPart* embeddedPart,
  617.                                                     ODTypeToken viewType,
  618.                                                     ODTypeToken presentation,
  619.                                                     ODID frameGroupID,
  620.                                                     FW_Boolean isOverlaid,
  621.                                                     FW_Boolean isSubFrame)
  622. {
  623.     
  624.     FW_CPresentation* myPresentation = GetPresentation(ev);
  625.     
  626.     CProxy* theBaseProxy = (CProxy*)baseProxy;
  627.     FW_CRect embeddedFrameBounds = theBaseProxy->GetBounds(ev);
  628.  
  629.     embeddedFrameBounds.Offset(embeddedFrameBounds.Width(), FW_kFixed0);
  630.     
  631.     CProxy* proxy = new CProxy(ev, embeddedFrameBounds, fContainerPart);
  632.         
  633.     FW_CRect tempRect(embeddedFrameBounds);
  634.     tempRect.Place(FW_kFixed0, FW_kFixed0);
  635.     FW_CAcquiredODShape aqFrameShape = ::FW_NewODShape(ev, tempRect);
  636.     
  637.     FW_TRY
  638.     {
  639.          myPresentation->Embed(ev, 
  640.                                 embeddedPart,
  641.                                 NULL,
  642.                                 kODFrameObject,
  643.                                 proxy,
  644.                                 aqFrameShape,
  645.                                 viewType,
  646.                                 presentation,
  647.                                 frameGroupID,
  648.                                 isOverlaid,
  649.                                 isSubFrame);
  650.     }
  651.     FW_CATCH_BEGIN
  652.     FW_CATCH_EVERYTHING () 
  653.     {
  654.         delete proxy;
  655.         FW_THROW_SAME ();
  656.     }
  657.     FW_CATCH_END
  658.     
  659.     // ----- Now I can add it to my data                
  660.     fContainerPart->AddProxyToPart(ev, proxy);
  661.  
  662.     // ----- Clip the facets -----
  663.     FW_CFacetClipper facetClipper(ev, fContainerPart);
  664.     FW_CAcquiredODShape limitShape = ::FW_NewODShape(ev, embeddedFrameBounds);
  665.     facetClipper.Clip(ev, myPresentation, limitShape);
  666.     
  667.     return proxy;
  668. }
  669.